<template>
  <el-form ref="dataForm" :rules="rules" :model="temp" label-position="left" label-width="70px" style="width: 400px; margin-left:500px;">
    <el-form-item label="标题" prop="warningName">
      <el-input v-model="temp.warningName" placeholder="请输入名称" />
    </el-form-item>
    <el-form-item label="文章内容" prop="solutionContent">
      <el-input v-model="temp.solutionContent" placeholder="请输入内容" />
    </el-form-item>
    <el-button @click="rrr">
      取消
    </el-button>
    <el-button type="primary" @click="updateData()">
      保存
    </el-button>
  </el-form>
</template>
<script>
import { addalertList, updatealertList, getalertList } from '@/api/alert'
import waves from '@/directive/waves' // waves directive
import { parseTime } from '@/utils'
import Pagination from '@/components/Pagination' // secondary package based on el-pagination
import { createStudent } from '@/api/system'

export default {
  name: 'ComplexTable',
  components: { Pagination },
  directives: { waves },
  data() {
    return {
      tableKey: 0,
      list: '',
      total: 0,
      listLoading: true,
      listQuery: {
        page: 1,
        limit: 20,
        name: '',
        grade: ''
      },
      // classoption:["大数据","计科","生信"],
      temp: {
        warningName: '',
        createUser: '',
        lastModifiedTime: '',
        solutionContent: '',
        earlyWarningId: ''
      },
      dialogFormVisible: false,
      dialogStatus: '',
      textMap: {
        update: 'Edit',
        create: 'Create'
      },
      dialogPvVisible: false,
      pvData: [],
      rules: {
        // className: [{ required: true, message: 'className is required', trigger: 'blur' }],
        // classGrade: [{ required: true, message: 'classGrade is required', trigger: 'blur' }],
        // classFields: [{ required: true, message: 'classFields is required', trigger: 'blur' }],
        // classMonitor: [{ required: true, message: 'classMonitor is required', trigger: 'blur' }],
      },
      downloadLoading: false
    }
  },
  created() {
    // console.log(this.list)
    this.getList()
  },
  methods: {
    getList() {
      this.temp.warningName = this.$route.params.warningName
      this.temp.solutionContent = this.$route.params.solutionContent
      this.temp.earlyWarningId = this.$route.params.earlyWarningId
      // console.log( this.$route.params.warningName)
      // console.log(this.temp)
    },
    rrr() {
      this.$router.push('/setting/index/1/alertManagement')
    },
    updateData() {
      const tempData = Object.assign({}, this.temp)
      // tempData.timestamp = +new Date(tempData.timestamp) // change Thu Nov 30 2017 16:41:05 GMT+0800 (CST) to 1512031311464
      console.log(tempData)
      tempData.createUser = 'fxz'
      updatealertList(tempData).then(() => {
        // this.dialogFormVisible = false
        this.$notify({
          title: 'Success',
          message: 'Update Successfully',
          type: 'success',
          duration: 2000
        })
        this.$router.push('/setting/index/1/alertManagement')
      })
    }

  }
}
</script>
